var express = require('express')
var router = express.Router()
const { getCaptchaService } = require('../service/captchaService')

// 请求验证码
router.get('/', async function(req, res, next) {
    // 获取验证码
    const captcha = await getCaptchaService()
    req.session.captcha = captcha.text
    // 设置响应头
    res.setHeader('Content-Type', 'image/svg+xml')
    // 响应验证码
    res.send(captcha.data)
    // console.log(result)
})

module.exports = router